package com.zzr.zzrbackend.controller;

import com.zzr.zzrbackend.pojo.domain.SituationRecordParent;
import com.zzr.zzrbackend.pojo.dto.CommonResult;
import com.zzr.zzrbackend.pojo.dto.param.DisabuseParam;
import com.zzr.zzrbackend.pojo.dto.param.DisabuseParentParam;
import com.zzr.zzrbackend.pojo.dto.param.DisabuseVolunteerParam;
import com.zzr.zzrbackend.pojo.dto.param.VolunteerScoreParam;
import com.zzr.zzrbackend.pojo.dto.result.*;
import com.zzr.zzrbackend.service.DisabuseService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;



@RestController
public class DisabuseController {

    @Resource
    private DisabuseService disabuseService;

    /**
     * 获取解惑列表
     *
     * @param request
     * @return
     */
    @RequestMapping(value = "/api/disabuse-list", method = RequestMethod.GET)
    public CommonResult<DisabuseListResult> getDisabuseList(HttpServletRequest request) {
        return disabuseService.getDisabuseList(request);
    }

    /**
     * 获取详细解惑信息
     *
     * @param request
     * @return
     */
    @RequestMapping(value = "/api/disabuse", method = RequestMethod.GET)
    public CommonResult<DisabuseResult> getDisabuse(HttpServletRequest request, Integer disabuseId) {
        return disabuseService.getDisabuseDetail(request, disabuseId);
    }

    /**
     * 获取志愿者解惑回答
     *
     * @param request
     * @return
     */
    @RequestMapping(value = "/api/disabuse/volunteer", method = RequestMethod.GET)
    public CommonResult<SituationVolunteerRecordResult> getDisabuseVolunteerDetail(HttpServletRequest request,
                                                                                   Integer disabuseId, Integer order) {
        return disabuseService.getDisabuseVolunteerDetail(request, disabuseId, order);
    }

    /**
     * 获取志愿者解惑回答
     *
     * @param request
     * @return
     */
    @RequestMapping(value = "/api/disabuse/volunteer-id", method = RequestMethod.GET)
    public CommonResult<NoData> getDisabuseVolunteerId(HttpServletRequest request,
                                                                                   Integer disabuseId) {
        return disabuseService.getDisabuseVolunteerId(request, disabuseId);
    }

    /**
     * 获取家长解惑回答
     *
     * @param request
     * @return
     */
    @RequestMapping(value = "/api/disabuse/parent", method = RequestMethod.GET)
    public CommonResult<SituationRecordParent> getDisabuseParentDetail(HttpServletRequest request, Integer disabuseId
            , Integer order) {
        return disabuseService.getDisabuseParentDetail(request, disabuseId, order);
    }

    /**
     * 小孩端提交解惑
     *
     * @param request
     * @return
     */
    @RequestMapping(value = "/api/disabuse", method = RequestMethod.POST)
    public CommonResult<NoData> setDisabuse(HttpServletRequest request, @RequestBody DisabuseParam disabuseParam) {
        return disabuseService.setDisabuse(request, disabuseParam);
    }

    /**
     * 家长提交解惑
     *
     * @param request
     * @return
     */
    @RequestMapping(value = "/api/disabuse/parent", method = RequestMethod.POST)
    public CommonResult<NoData> setParentDisabuse(HttpServletRequest request,
                                                  @RequestBody DisabuseParentParam disabuseParentParam) {
        return disabuseService.setParentDisabuse(request, disabuseParentParam);
    }

    /**
     * 志愿者提交解惑
     *
     * @param request
     * @return
     */
    @RequestMapping(value = "/api/disabuse/volunteer", method = RequestMethod.POST)
    public CommonResult<NoData> setVolunteerDisabuse(HttpServletRequest request,
                                                     @RequestBody DisabuseVolunteerParam disabuseVolunteerParam) {
        return disabuseService.setVolunteerDisabuse(request, disabuseVolunteerParam);
    }

    /**
     * 获取解惑次数
     *
     * @param request
     * @return
     */
    @RequestMapping(value = "/api/disabuse/num", method = RequestMethod.GET)
    public CommonResult<DisabuseCountResult> getDisabuseCount(HttpServletRequest request, Integer disabuseId) {
        return disabuseService.getDisabuseCount(request, disabuseId);
    }

    /**
     * 获取解惑次数
     *
     * @param request
     * @return
     */
    @RequestMapping(value = "/api/disabuse/single-num", method = RequestMethod.GET)
    public CommonResult<SingleDisabuseCountNum> getSingleDisabuseCount(HttpServletRequest request, Integer disabuseId
            , Integer type) {
        return disabuseService.getSingleDisabuseCount(request, disabuseId, type);
    }

    /**
     * 解惑获取个人基本信息
     *
     * @param request
     * @return
     */
    @RequestMapping(value = "/api/disabuse/personal-information", method = RequestMethod.GET)
    public CommonResult<PersonalInformationResult> getPersonalInformation(HttpServletRequest request,
                                                                          Integer disabuseId) {
        return disabuseService.getPersonalInformation(request, disabuseId);
    }

    /**
     * 完成解惑
     *
     * @param request
     * @return
     */
    @RequestMapping(value = "/api/disabuse/solve", method = RequestMethod.POST)
    public CommonResult<NoData> setSolve(HttpServletRequest request, Integer disabuseId) {
        return disabuseService.setSolve(request, disabuseId);
    }

    /**
     * 确认解惑
     *
     * @param request
     * @return
     */
    @RequestMapping(value = "/api/disabuse/accept-solve", method = RequestMethod.POST)
    public CommonResult<NoData> setAcceptSolve(HttpServletRequest request, Integer disabuseId) {
        return disabuseService.setAcceptSolve(request, disabuseId);
    }

    /**
     * 志愿者接受解惑
     *
     * @param request
     * @return
     */
    @RequestMapping(value = "/api/disabuse/accept", method = RequestMethod.POST)
    public CommonResult<NoData> setAcceptId(HttpServletRequest request, Integer disabuseId) {
        return disabuseService.setAcceptId(request, disabuseId);
    }

    /**
     * 查看未解决解惑数量
     *
     * @param request
     * @return
     */
    @RequestMapping(value = "/api/disabuse/not-solve/num", method = RequestMethod.GET)
    public CommonResult<NoData> getNotSolveDisabuseNum(HttpServletRequest request) {
        return disabuseService.getNotSolveDisabuseNum(request);
    }

    @PostMapping("/api/volunteer/set-score")
    public CommonResult<NoData> setVolunteerScore(@Validated @RequestBody VolunteerScoreParam volunteerScoreParam){
        return disabuseService.setVolunteerScore(volunteerScoreParam);
    }

}
